package base.controller;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import DTO.User;

/**
 * Testing of EL cookie implict obj.
 */
public class ELCookieTest extends HttpServlet {
    private static final long serialVersionUID = 1L;

    public ELCookieTest() {
	super();
    }

    protected void doGet(HttpServletRequest request,
	    HttpServletResponse response) throws ServletException, IOException {
	doPost(request, response);
    }

    protected void doPost(HttpServletRequest request,
	    HttpServletResponse response) throws ServletException, IOException {
	String name = "JIN";
	User user = new User();
	user.setAlias("Sam");

	response.setContentType("text/html");

	request.setAttribute("user", user);
	Cookie nameCookie = new Cookie("name", name);
	response.addCookie(nameCookie);

	RequestDispatcher view = request
		.getRequestDispatcher("/WEB-INF/views/nameCookie.jsp");
	view.forward(request, response);
    }
}
